<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{$basic.title}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link href="__LAYUI__/css/layui.css" rel="stylesheet">
    <link href="__LAYUI__/css/ah.css" rel="stylesheet">
</head>
<body>
<div class="wrapper-content">
<div class="ibox">
	<div class="ibox-title"><h3></h3>
	<div class="ibox-tools">
					<div class="layui-btn-group" id="amTools">
						{:getTool(['re','add'],$toolUrl)}
					  </div>            
		</div>
	
	</div>
	<div class="ibox-content">
		<form class="layui-form">
													<div class="layui-form-item">
													  <div class="layui-input-block">
														<div id="LAY-auth-tree-index"></div>
													  </div>
													</div>
		</form>
	</div>
</div>
</div>
</body>
<script src="__LAYUI__/layui.js"></script>
<script>
layui.config({
	base: '__LAYUI__/exts/',
}).extend({
	authtree: 'authtree',
});
	layui.use(['jquery', 'authtree','form', 'layer'], function(){
		
	  var $ = layui.jquery;
	  var authtree = layui.authtree;
	  var form = layui.form;
	  var layer = layui.layer;
	  var xaoam ={
		  tool:function(){
			form.on('checkbox', function(res){
				var id = $(this).val();
				var url = '{:url("tag/edit")}?id='+id;
				xaoam.newWin(url,'');
		    });
			  $('#amTools [type="button"]').on('click',function(ele){
					if($(this).hasClass('am_re')){
						xaoam.init();// 初始化
					}
					if($(this).hasClass('am_add')){
						xaoam.newWin($(this).data('url'),'');
					}
					if($(this).hasClass('am_dels')){
						console.log(2);
					}

			  });
		  },
		  newWin:function(url,text){
			 var index = layer.open({ type: 2,
			  				  title: [text, 'font-size:18px;'],
			  				  content: url,
			  				});
			  		layer.full(index);
		  },
		  init:function(){
			    $.ajax({
			      url: "{:url('tag/lists')}",
			      dataType: 'json',
			      success: function(data){
					  $('.ibox-title h3').text(data.msg);
			  	  var trees = authtree.listConvert(data.data, {
			  	      primaryKey: 'id'
			  	      ,startPid: 0
			  	      ,parentKey: 'parentId'
			  	      ,nameKey: 'name'
			  	      ,valueKey: 'id'
			  	  });
				  
			        authtree.render('#LAY-auth-tree-index', trees, {
			          inputname: 'ids[]'
			          ,layfilter: 'lay-check-auth'
			          ,'theme': 'auth-skin-default'
			          ,'themePath': '__LAYUI__/exts/themes/'
			          ,autowidth: true
						,hidechoose: true
			        });
			  	 }
			  });
		  }
	  } 

		xaoam.tool();
		xaoam.init();// 初始化
		window.Wxaoam = xaoam;
	});
</script>

</html>
